package top.springcloud.FeignConsumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.springcloud.FeignConsumer.service.CustomerService;
import top.springcloud.FeignConsumer.service.HelloService;
import top.springcloud.customer.entity.Customer;

import java.util.Date;

/**
 * 模拟消费者
 */
@RestController
public class BaseConsumerController {

    @Autowired
    private HelloService helloService;
    @Autowired
    private CustomerService customerService;

   /* @RequestMapping(value="/hello",method = RequestMethod.GET)
    public String hello(@RequestParam String name){
        System.out.println("This is FeignConsumer ...");
        return helloService.getHello(name);
    }*/

    @RequestMapping(value="/customer/get/{customerId}",method = RequestMethod.GET)
    public String getCustomerById(@PathVariable Integer customerId){
        System.out.println("get customerById ...");
        return customerService.getCustomerById(customerId);
    }

    @RequestMapping("/customer/save")
    public Customer saveCustomer(){
        Customer customer = new Customer();
        customer.setCustomerName("testCustomer");
        customer.setCreateTime(new Date());
        customer.setPasswd("111111");
        customer = customerService.saveCustomer(customer);
        System.out.println(customer);
        return customer;
    }


}
